//
// Created by Administrator on 2025/9/3.
//
#include <algorithm>
#include <string>
#include <map>
#include <iostream>

int main()
{
    std::map<std::string, size_t> word_count; // empty map from string to size_t
    std::string word;
    std::cout << "Enter a word: ";
    while (std::cin >> word)
    {
        std::transform(word.begin(), word.end(), word.begin(), tolower);
        // std::cout << word << std::endl;
        ++word_count[word]; // fetch and increment the counter for word
    }
    for (const auto& w : word_count) // for each element in the map
        // print the results
        std::cout << w.first << " occurs " << w.second
            << ((w.second > 1) ? " times" : " time") << std::endl;
}
